package com.example.demo.controller;

import com.example.demo.common.ResultAjax;
import com.example.demo.domin.dto.UserDTO;
import com.example.demo.domin.entity.User;
import com.example.demo.domin.vo.UserVO;
import com.example.demo.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class SysUserController {
    @Resource
    UserService userService;

    @PostMapping("/signUp")
    public ResultAjax<Object> signUpuser(@RequestBody UserDTO user){
        userService.signUpUser(user);
        return ResultAjax.success();
    }

    @PostMapping("/login")
    public ResultAjax login(@RequestBody UserDTO userDTO){
        String login = userService.login(userDTO);
        return ResultAjax.success(login);
    }

    @GetMapping("/list")
    public ResultAjax<List<UserVO>> userList(){
        List<UserVO> list = userService.getUserList();
        return ResultAjax.success(list);
    }


}
